home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / wemdemo4.zip / INFO / LEMACS.2 (.txt) < prev    next >
GNU Info File  |  1994-09-21  |  51KB  |  901 lines

  1. This is Info file ../info/lemacs, produced by Makeinfo-1.55 from the
  2. input file lemacs.txi.
  3.    This file documents the GNU Emacs editor.
  4.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
  5. 1991, 1992 Lucid, Inc.
  6.    Permission is granted to make and distribute verbatim copies of this
  7. manual provided the copyright notice and this permission notice are
  8. preserved on all copies.
  9.    Permission is granted to copy and distribute modified versions of
  10. this manual under the conditions for verbatim copying, provided also
  11. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  12. General Public License" are included exactly as in the original, and
  13. provided that the entire resulting derived work is distributed under the
  14. terms of a permission notice identical to this one.
  15.    Permission is granted to copy and distribute translations of this
  16. manual into another language, under the above conditions for modified
  17. versions, except that the sections entitled "The GNU Manifesto",
  18. "Distribution" and "GNU General Public License" may be included in a
  19. translation approved by the author instead of in the original English.
  20. File: lemacs,  Node: Character Representation,  Next: Commands,  Prev: Super and Hyper Keys,  Up: Keystrokes
  21. Representation of Characters
  22. ============================
  23.    This section briefly discusses how characters are represented in
  24. Emacs buffers.  *Note Key Sequences:: for information on representing
  25. key sequences to create key bindings.
  26.    ASCII graphic characters in Emacs buffers are displayed with their
  27. graphics.  LFD is the same as a newline character; it is displayed by
  28. starting a new line.  TAB is displayed by moving to the next tab stop
  29. column (usually every 8 spaces).  Other control characters are
  30. displayed as a caret (`^') followed by the non-control version of the
  31. character; thus, `C-a' is displayed as `^A'.  Non-ASCII characters 128
  32. and up are displayed with octal escape sequences; thus, character code
  33. 243 (octal), also called `M-#' when used as an input character, is
  34. displayed as `\243'.
  35.    The variable `ctl-arrow' may be used to alter this behavior.  *Note
  36. Display Vars::.
  37. File: lemacs,  Node: Commands,  Next: Pull-down Menus,  Prev: Character Representation,  Up: Top
  38. Keys and Commands
  39. =================
  40.    This manual is full of passages that tell you what particular keys
  41. do.  But Emacs does not assign meanings to keys directly.  Instead,
  42. Emacs assigns meanings to "functions", and then gives keys their
  43. meanings by "binding" them to functions.
  44.    A function is a Lisp object that can be executed as a program.
  45. Usually it is a Lisp symbol that has been given a function definition;
  46. every symbol has a name, usually made of a few English words separated
  47. by dashes, such as `next-line' or `forward-word'.  It also has a
  48. "definition", which is a Lisp program.  Only some functions can be the
  49. bindings of keys; these are functions whose definitions use
  50. `interactive' to specify how to call them interactively.  Such
  51. functions are called "commands", and their names are "command names".
  52. More information on this subject will appear in the GNU Emacs Lisp
  53. Manual.
  54.    The bindings between keys and functions are recorded in various
  55. tables called "keymaps".  *Note Key Bindings:: for more information on
  56. key sequences you can bind commands to.  *Note Keymaps:: for
  57. information on creating keymaps.
  58.    When we say  "`C-n' moves down vertically one line" we are glossing
  59. over a distinction that is irrelevant in ordinary use but is vital in
  60. understanding how to customize Emacs.  The function `next-line' is
  61. programmed to move down vertically.  `C-n' has this effect because it
  62. is bound to that function.  If you rebind `C-n' to the function
  63. `forward-word' then `C-n' will move forward by words instead.
  64. Rebinding keys is a common method of customization.
  65.    The rest of this manual usually ignores this subtlety to keep things
  66. simple.  To give the customizer the information needed, we often state
  67. the name of the command that really does the work in parentheses after
  68. mentioning the key that runs it.  For example, we will say that "The
  69. command `C-n' (`next-line') moves point vertically down," meaning that
  70. `next-line' is a command that moves vertically down and `C-n' is a key
  71. that is standardly bound to it.
  72.    While we are on the subject of information for customization only,
  73. it's a good time to tell you about "variables".  Often the description
  74. of a command will say, "To change this, set the variable `mumble-foo'."
  75. A variable is a name used to remember a value.  Most of the variables
  76. documented in this manual exist just to facilitate customization: some
  77. command or other part of Emacs uses the variable and behaves
  78. differently depending on its setting.  Until you are interested in
  79. customizing, you can ignore the information about variables.  When you
  80. are ready to be interested, read the basic information on variables,
  81. then the information on individual variables will make sense.  *Note
  82. Variables::.
  83. File: lemacs,  Node: Pull-down Menus,  Next: Mouse Selection,  Prev: Commands,  Up: Top
  84. Lucid GNU Emacs Pull-down Menus
  85. ===============================
  86.    If you are running Lucid GNU Emacs under X, a menu bar on top of the
  87. Emacs screen provides access to pull-down menus of file, edit, and
  88. help-related commands. The menus provide convenient shortcuts and an
  89. easy interface for novice users.  They do not provide additions to the
  90. functionality available via key commands; you can still invoke commands
  91. from the keyboard as in previous versions of Emacs.
  92.      Perform file and buffer-related operations, such as opening and
  93.      closing files, saving and printing buffers, as well as exiting
  94.      Emacs.
  95.      Perform standard editing operations, such as cutting, copying,
  96.      pasting and killing selected text.
  97. Buffers
  98.      Present a menu of buffers for selection as well as the option to
  99.      display a buffer list.
  100.      Access to Emacs Info.
  101.    There are two ways of selecting an item from a pull-down menu:
  102.    * Select an item in the menu bar by moving the cursor over it and
  103.      click the left mouse-button.  Then move the cursor over the item
  104.      you want to choose and click left again.
  105.    * Select an item in the menu bar by moving the cursor over it and
  106.      click and hold the left mouse-button.  With the mouse-button
  107.      depressed, move the cursor over the item you want, then release it
  108.      to make your selection.
  109.    If a command in the pull-down menu is not applicable in a given
  110. situation, the command is disabled and its name appears faded.  You
  111. cannot invoke items that are faded.  For example, most commands on the
  112. Edit menu appear faded until you select text on which they are to
  113. operate; after you select a block of text, edit commands are enabled.
  114. *Note Mouse Selection:: for information on using the mouse to select
  115. text.  *Note Using X Selections:: for related information.
  116.    There are also `M-x' equivalents for each menu item.  To find the
  117. equivalent for any left-button menu item, do the following:
  118.   1. Type `C-h k' to get the `Describe Key' prompt.
  119.   2. Select the menu item and click.
  120.    Emacs displays the function associated with the menu item in a
  121. separate window, usually together with some documentation.
  122. * Menu:
  123. * File Menu::           Items on the File menu.
  124. * Edit Menu::           Items on the Edit menu.
  125. * Buffers Menu::        Information about the Buffers menu
  126. * Help Menu::           Items on the Help menu.
  127. * Menu Customization::  Adding and removing menu items and related
  128.                         operations.
  129. File: lemacs,  Node: File Menu,  Next: Edit Menu,  Prev: Pull-down Menus,  Up: Pull-down Menus
  130. The File Menu
  131. .............
  132.    The File menu bar item contains the items New Screen, Open File...,
  133. Save Buffer, Save Buffer As..., Revert Buffer, Print Buffer, Delete
  134. Screen, Kill Buffer and Exit Emacs on the pull-down menu.  If you
  135. select a menu item, Emacs executes the equivalent command.
  136. New Screen
  137.      Creates a new Emacs screen, that is, a new X window running under
  138.      the same Emacs process.  You can remove the screen using the Delete
  139.      Screen menu item. When you remove the last screen, you exit Emacs
  140.      and are prompted for confirmation.  This is bound to `C-x 5' by
  141.      default.
  142. Open File...
  143.      Prompts you for a filename and loads that file into a new buffer.
  144.      Open File... is equivalent to the Emacs command `find-file' (`C-x
  145.      C-f').
  146. Save Buffer
  147.      Writes and saves the current Emacs buffer as the latest version of
  148.      the current visited file.  Save Buffer is equivalent to the Emacs
  149.      command `save-buffer' (`C-x C-s').
  150. Save Buffer As...
  151.      Writes and saves the current Emacs buffer to the filename you
  152.      specify.  Save Buffer As... is equivalent to the Emacs command
  153.      `write-file' (`C-x C-w').
  154. Revert Buffer
  155.      Restores the last saved version of the file to the current buffer.
  156.      When you edit a buffer containing a text file, you must save the
  157.      buffer before your changes become effective.  Use Revert Buffer if
  158.      you do not want to keep the changes you have made in the buffer.
  159.      Revert Buffer is equivalent to the Emacs command `revert-file'
  160.      (`M-x revert-buffer').
  161. Print Buffer
  162.      Prints a hardcopy of the current buffer.  Equivalent to the Emacs
  163.      command `print-buffer' (`M-x print-buffer').
  164. Delete Screen
  165.      Allows you to close all but one of the screens created by New
  166.      Screen.  If you created several Emacs screens belonging to the
  167.      same Emacs process, you can close all but one of them.  When you
  168.      attempt to close the last screen, Emacs informs you that you are
  169.      attempting to delete the last screen.  You have to choose Exit
  170.      Emacs for that.
  171. Kill Buffer...
  172.      Prompts you for the name of a buffer to kill. The default is the
  173.      name of the currently selected buffer. Kill Buffer is equivalent
  174.      to the Emacs command `kill-buffer' (`C-x k').
  175. Exit Emacs
  176.      Shuts down (kills) the Emacs process.  Equivalent to the Emacs
  177.      command `save-buffers-kill-emacs' (`C-x C-c').  Before killing the
  178.      Emacs process, the system asks which unsaved buffers to save by
  179.      going through the list of all buffers in that Emacs process.
  180. File: lemacs,  Node: Edit Menu,  Next: Buffers Menu,  Prev: File Menu,  Up: Pull-down Menus
  181. The Edit Menu
  182. .............
  183.    The Edit pull-down menu contains the Undo, Cut, Copy, Paste and
  184. Clear menu items.  When you select a menu item, Emacs executes the
  185. equivalent command.  Most commands on the Edit menu work on a block of
  186. text, the X selection.  They appear faded until you select a block of
  187. text (activate a region) with the mouse.  *Note Using X Selections::,
  188. *note Killing::., and *note Yanking::. for more information.
  189.      Undoes the previous command.  Undo is equivalent to the Emacs
  190.      command `undo' (`C-x u').
  191.      Removes the selected text block from the current buffer, makes it
  192.      the X clipboard selection, and places it in the kill ring.  Before
  193.      executing this command, you have to select a region using Emacs
  194.      region selection commands or with the mouse.
  195.      Makes a selected text block the X clipboard selection, and places
  196.      it in the kill ring.  You can select text using one of the Emacs
  197.      region selection commands or select a text region with the mouse.
  198. Paste
  199.      Inserts the current value of the X clipboard selection in the
  200.      current buffer.  Note that this is not necessarily the same as the
  201.      Emacs `yank' command because the Emacs kill ring and the X
  202.      clipboard selection are not the same thing.  You can paste in text
  203.      you have placed in the clipboard using Copy or Cut.  You can also
  204.      use Paste to insert text that was pasted into the clipboard from
  205.      other applications.
  206. Clear
  207.      Removes the selected text block from the current buffer but does
  208.      not place it in the kill ring or the X clipboard selection.
  209. File: lemacs,  Node: Buffers Menu,  Next: Help Menu,  Prev: Edit Menu,  Up: Pull-down Menus
  210. The Buffers Menu
  211. ................
  212.    The Buffers menu provides a selection of up to ten buffers and the
  213. item List All Buffers, which provides a Buffer List. *Note List
  214. Buffers:: for more information.
  215. File: lemacs,  Node: Help Menu,  Next: Menu Customization,  Prev: Buffers Menu,  Up: Pull-down Menus
  216. The Help Menu
  217. .............
  218.    The Help Menu gives you access to Emacs Info and provides a menu
  219. equivalents for each of the choices you have when using `C-h'.  *Note
  220. Help:: for more information.
  221.    The Help menu also gives access to UNIX online manual pages via the
  222. UNIX Manual Page option.
  223. File: lemacs,  Node: Menu Customization,  Prev: Help Menu,  Up: Pull-down Menus
  224. Customizing Lucid GNU Emacs Menus
  225. ---------------------------------
  226.    You can customize any of the pull-down menus by adding or removing
  227. menu items and disabling or enabling existing menu items.
  228.    The following functions are available:
  229. `add-menu: (MENU-PATH MENU-NAME MENU-ITEMS &OPTIONAL BEFORE)'
  230.      Add a menu to the menubar or one of its submenus.
  231. `add-menu-item: (MENU-PATH ITEM-NAME FUNCTION ENABLED-P &OPTIONAL BEFORE)'
  232.      Add a menu item to a menu, creating the menu first if necessary.
  233. `delete-menu-item: (PATH)'
  234.      Remove the menu item defined by PATH from the menu hierarchy.
  235. `disable-menu-item: (PATH)'
  236.      Disable the specified menu item.
  237. `enable-menu-item: (PATH)'
  238.      Enable the specified previously disabled menu item.
  239. `relabel-menu-item: (PATH NEW-NAME)'
  240.      Change the string of the menu item specified by PATH to NEW-NAME.
  241.    Use the function `add-menu' to add a new menu or submenu.  If a menu
  242. or submenu of the given name exists already, it is changed.
  243.    MENU-PATH identifies the menu under which the new menu should be
  244. inserted.  It is a list of strings; for example, `("File")' names the
  245. top-level File menu.  `("File" "Foo")' names a hypothetical submenu of
  246. File.  If MENU-PATH is `nil', the menu is added to the menubar itself.
  247.    MENU-NAME is the string naming the menu to be added.
  248.    MENU-ITEMS is a list of menu item descriptions.  Each menu item
  249. should be a vector of three elements:
  250.    * A string, which is the name of the menu item.
  251.    * A symbol naming a command, or a form to evaluate.
  252.    * `t' or `nil' to indicate whether the item is selectable.
  253.    The optional argument BEFORE is the name of the menu before which
  254. the new menu or submenu should be added.  If the menu is already
  255. present, it is not moved.
  256.    The function `add-menu-item' adds a menu item to the specified menu,
  257. creating the menu first if necessary.  If the named item already
  258. exists, the menu remains unchanged.
  259.    MENU-PATH identifies the menu into which the new menu item should be
  260. inserted.  It is a list of strings; for example, `("File")' names the
  261. top-level File menu.  `("File" "Foo")' names a hypothetical submenu of
  262. File.
  263.    ITEM-NAME is the string naming the menu item to add.
  264.    FUNCTION is the command to invoke when this menu item is selected.
  265. If it is a symbol, it is invoked with `call-interactively', in the same
  266. way that functions bound to keys are invoked.  If it is a list, the
  267. list is simply evaluated.
  268.    ENABLED-P controls whether the item is selectable or not.
  269.    For example, to make the `rename-file' command available from the
  270. File menu, use the following code:
  271.      (add-menu-item '("File") "Rename File" 'rename-file t)
  272.    To add a submenu of file management commands using a File Management
  273. item, use the following code:
  274.      (add-menu-item '("File" "File Management") "Copy File" 'copy-file t)
  275.      (add-menu-item '("File" "File Management") "Delete File" 'delete-file t)
  276.      (add-menu-item '("File" "File Management") "Rename File" 'rename-file t)
  277.    The optional BEFORE argument is the name of a menu item before which
  278. the new item should be added.  If the item is already present, it is
  279. not moved.
  280.    To remove a specified menu item from the menu hierarchy, use
  281. `delete-menu-item'.
  282.    PATH is a list of strings that identify the position of the menu
  283. item in the menu hierarchy.  `("File" "Save")' means the menu item
  284. called Save under the top level File menu.  `("Menu" "Foo" "Item")'
  285. means the menu item called Item under the FOO submenu of MENU.
  286.    To disable a menu item, use `disable-menu-item'.  The disabled menu
  287. item is grayed and can no longer be selected.  To make the item
  288. selectable again, use `enable-menu-item'.  `disable-menu-item' and
  289. `enable-menu-item' both have the argument PATH.
  290.    To change the string of the specified menu item, use
  291. `relabel-menu-item'. This function also takes the argument PATH.
  292.    NEW-NAME is the string to which the menu item will be changed.
  293. File: lemacs,  Node: Entering Emacs,  Next: Exiting,  Prev: Mouse Selection,  Up: Top
  294. Entering and Exiting Emacs
  295. **************************
  296.    The usual way to invoke Emacs is to type `emacs RET' at the shell.
  297. To invoke Lucid GNU Emacs, type `lemacs RET'.  Emacs clears the screen
  298. and then displays an initial advisory message and copyright notice.
  299. You can begin typing Emacs commands immediately afterward.
  300.    Some operating systems insist on discarding all type-ahead when Emacs
  301. starts up; they give Emacs no way to prevent this.  Therefore, it is
  302. wise to wait until Emacs clears the screen before typing the first
  303. editing command.
  304.    Before Emacs reads the first command, you have not had a chance to
  305. give a command to specify a file to edit.  Since Emacs must always have
  306. a current buffer for editing, it presents a buffer, by default, a
  307. buffer named `*scratch*'.  The buffer is in Lisp Interaction mode; you
  308. can use it to type Lisp expressions and evaluate them, or you can
  309. ignore that capability and simply doodle.  You can specify a different
  310. major mode for this buffer by setting the variable `initial-major-mode'
  311. in your init file.  *Note Init File::.
  312.    It is possible to give Emacs arguments in the shell command line to
  313. specify files to visit, Lisp files to load, and functions to call.
  314. File: lemacs,  Node: Exiting,  Next: Command Switches,  Prev: Entering Emacs,  Up: Top
  315. Exiting Emacs
  316. =============
  317.    There are two commands for exiting Emacs because there are two kinds
  318. of exiting: "suspending" Emacs and "killing" Emacs.  "Suspending" means
  319. stopping Emacs temporarily and returning control to its superior
  320. (usually the shell), allowing you to resume editing later in the same
  321. Emacs job, with the same files, same kill ring, same undo history, and
  322. so on.  This is the usual way to exit.  "Killing" Emacs means
  323. destroying the Emacs job.  You can run Emacs again later, but you will
  324. get a fresh Emacs; there is no way to resume the same editing session
  325. after it has been killed.
  326. `C-z'
  327.      Suspend Emacs (`suspend-emacs').  If used under the X window
  328.      system, shrink the X window containing the Emacs screen to an
  329.      icon.  (see below)
  330. `C-x C-c'
  331.      Kill Emacs (`save-buffers-kill-emacs').
  332.    If you use Lucid GNU Emacs under the X window system, `C-z' shrinks
  333. the X window containing the Emacs screen to an icon.  The Emacs process
  334. is stopped temporarily, and control is returned to the window manager.
  335. If more than one screen is associated with the Emacs process, only the
  336. screen from which you used `C-z' is retained.  The X windows containing
  337. the other Emacs screens are closed.
  338.    To activate the "suspended" Emacs, use the appropriate window manager
  339. mouse gestures.  Usually left-clicking on the icon reactivates and
  340. reopens the X window containing the Emacs screen, but the window manager
  341. you use determines what exactly happens.  To actually kill the Emacs
  342. process, use `C-x C-c' or the Exit Emacs item on the File menu.
  343.    On systems that do not permit programs to be suspended, `C-z' runs
  344. an inferior shell that communicates directly with the terminal, and
  345. Emacs waits until you exit the subshell.  On these systems, the only way
  346. to return to the shell from which Emacs was started (to log out, for
  347. example) is to kill Emacs.  `C-d' or `exit' are typical commands to
  348. exit a subshell.
  349.    To kill Emacs, type `C-x C-c' (`save-buffers-kill-emacs').  A
  350. two-character key is used for this to make it harder to type.  In Lucid
  351. GNU Emacs, selecting the Exit Emacs option of the File menu is an
  352. alternate way of issuing the command.
  353.    Unless a numeric argument is used, this command first offers to save
  354. any modified buffers.  If you do not save all buffers, you are asked for
  355. reconfirmation with `yes' before killing Emacs, since any changes not
  356. saved will be lost.  If any subprocesses are still running, `C-x C-c'
  357. asks you to confirm killing them, since killing Emacs kills the
  358. subprocesses simultaneously.
  359.    In most programs running on Unix, certain characters may instantly
  360. suspend or kill the program.  (In Berkeley Unix these characters are
  361. normally `C-z' and `C-c'.)  This Unix feature is turned off while you
  362. are in Emacs. The meanings of `C-z' and `C-x C-c' as keys in Emacs were
  363. inspired by the standard Berkeley Unix meanings of `C-z' and `C-c', but
  364. that is their only relationship with Unix.  You could customize these
  365. keys to do anything (*note Keymaps::.).
  366. File: lemacs,  Node: Command Switches,  Next: Basic,  Prev: Exiting,  Up: Top
  367. Command Line Switches and Arguments
  368. ===================================
  369.    GNU Emacs supports command line arguments you can use to request
  370. various actions when invoking Emacs.  The commands are for compatibility
  371. with other editors and for sophisticated activities.  If you are using
  372. Lucid GNU Emacs under the X window system, you can also use a number of
  373. standard Xt command line arguments. Command line arguments are not
  374. usually needed for editing with Emacs; new users can skip this section.
  375.    Many editors are designed to be started afresh each time you want to
  376. edit.  You start the editor to edit one file; then exit the editor.  The
  377. next time you want to edit either another file or the same one, you
  378. start the editor again.  Under these circumstances, it makes sense to
  379. use a command line argument to say which file to edit.
  380.    The recommended way to use GNU Emacs is to start it only once, just
  381. after you log in, and do all your editing in the same Emacs process.
  382. Each time you want to edit a file, you visit it using the existing
  383. Emacs.  Emacs creates a new buffer for each file and (unless you kill
  384. some of the buffers), Emacs eventually has many files in it ready for
  385. editing.  Usually you do not kill the Emacs process until you are about
  386. to log out.  Since you usually read files by typing commands to Emacs,
  387. command line arguments for specifying a file Emacs is started are seldom
  388. needed.
  389.    Emacs accepts command-line arguments that specify files to visit,
  390. functions to call, and other activities and operating modes.  If you are
  391. running Lucid GNU Emacs under the X window system, a number of standard
  392. Xt command line arguments are available as well.
  393.    The following sections list:
  394.    * Command line arguments that you can always use.
  395.    * Command line arguments that have to appear at the beginning of the
  396.      argument list.
  397.    * Command line arguments that are only relevant if you are running
  398.      Lucid GNU Emacs under X.
  399.    Command line arguments are processed in the order they appear on the
  400. command line; however, certain arguments (the ones in the second table)
  401. must be at the front of the list if they are used.
  402.    Here are the arguments allowed:
  403. `FILE'
  404.      Visit FILE using `find-file'.  *Note Visiting::.
  405. `+LINENUM FILE'
  406.      Visit FILE using `find-file', then go to line number LINENUM in it.
  407. `-l FILE'
  408. `-load FILE'
  409.      Load a file FILE of Lisp code with the function `load'.  *Note
  410.      Lisp Libraries::.
  411. `-f FUNCTION'
  412. `-funcall FUNCTION'
  413.      Call Lisp function FUNCTION with no arguments.
  414. `-i FILE'
  415. `-insert FILE'
  416.      Insert the contents of FILE into the current buffer.  This is like
  417.      what `M-x insert-buffer' does; *Note Misc File Ops::.
  418. `-kill'
  419.      Exit from Emacs without asking for confirmation.
  420. `-version'
  421.      Prints version information.  This implies `-batch'.
  422.           % emacs -version
  423.           GNU Emacs 19.4 Lucid of Mon Dec 28 1992 on thalidomide (berkeley-unix)
  424. `-help'
  425.      Prints a summary of command-line options, and exits.
  426.    The following arguments are recognized only at the beginning of the
  427. command line.  If more than one of them appears, they must appear in the
  428. order in which they appear in this table.
  429. `-t FILE'
  430.      Use FILE instead of the terminal for input and output. (This
  431.      option is currently not valid in Lucid GNU Emacs)
  432. `-batch'
  433.      Run Emacs in "batch mode", which means that the text being edited
  434.      is not displayed and the standard Unix interrupt characters such as
  435.      `C-z' and `C-c' continue to have their normal effect.  Emacs in
  436.      batch mode outputs to `stderr' only what would normally be printed
  437.      in the echo area under program control.
  438.      Batch mode is used for running programs written in Emacs Lisp from
  439.      shell scripts, makefiles, and so on.  Normally the `-l' switch or
  440.      `-f' switch will be used as well, to invoke a Lisp program to do
  441.      the batch processing.
  442.      `-batch' implies `-q' (do not load an init file).  It also causes
  443.      Emacs to kill itself after all command switches have been
  444.      processed.  In addition, auto-saving is not done except in buffers
  445.      for which it has been explicitly requested.
  446. `-no-init-file'
  447.      Do not load your Emacs init file `~/.emacs'.
  448. `-u USER'
  449. `-user USER'
  450.      Load USER's Emacs init file `~USER/.emacs' instead of your own.
  451.    Note that the init file can get access to the command line argument
  452. values as the elements of a list in the variable `command-line-args'.
  453. (The arguments in the second table above will already have been
  454. processed and will not be in the list.)  The init file can override the
  455. normal processing of the other arguments by setting this variable.
  456.    One way to use command switches is to visit many files automatically:
  457.      emacs *.c
  458. passes each `.c' file as a separate argument to Emacs, so that Emacs
  459. visits each file (*note Visiting::.).
  460.    Here is an advanced example that assumes you have a Lisp program file
  461. called `hack-c-program.el' which, when loaded, performs some useful
  462. operation on the current buffer, expected to be a C program.
  463.      emacs -batch foo.c -l hack-c-program -f save-buffer -kill > log
  464. Here Emacs is told to visit `foo.c', load `hack-c-program.el' (which
  465. makes changes in the visited file), save `foo.c' (note that
  466. `save-buffer' is the function that `C-x C-s' is bound to), and then
  467. exit to the shell from which the command was executed.  `-batch'
  468. guarantees there will be no problem redirecting output to `log',
  469. because Emacs will not assume that it has a display terminal to work
  470. with.
  471.    If you are running Lucid GNU Emacs under X, a number of options are
  472. available to control color, border, and window title and icon name:
  473. `-T TITLE'
  474. `-wn TITLE'
  475.      Use TITLE as the window title. This sets the `screen-title-format'
  476.      variable, which controls the title of the X window corresponding
  477.      to the selected screen.  This is the same format as
  478.      `mode-line-format'.
  479. `-in TITLE'
  480. `-iconname TITLE'
  481.      Use TITLE as the icon name. This sets the
  482.      `screen-icon-title-format' variable, which controls the title of
  483.      the icon corresponding to the selected screen.
  484. `-mc COLOR'
  485.      Use COLOR as the mouse color.
  486. `-cr COLOR'
  487.      Use COLOR as the text-cursor foreground color.
  488.    In addition, Lucid GNU Emacs allows you to use a number of standard
  489. Xt command line arguments.
  490. `-bg COLOR'
  491. `-background COLOR'
  492.      Use COLOR as the background color.
  493. `-bd COLOR'
  494. `-bordercolor COLOR'
  495.      Use COLOR as the border color.
  496. `-bw WIDTH'
  497. `-borderwidth WIDTH'
  498.      Use WIDTH as the border width.
  499. `-d DISPLAY'
  500. `-display DISPLAY'
  501. `-d DISPLAY'
  502.      When running under the X window system, create the window
  503.      containing the Emacs screen on the display named DISPLAY.
  504. `-fg COLOR'
  505. `-foreground COLOR'
  506.      Use COLOR as the foreground color.
  507. `-fn NAME'
  508. `-font NAME'
  509.      Use NAME as the font.
  510. `-g SPEC'
  511. `-geom SPEC'
  512. `-geometry SPEC'
  513.      Use the geometry specified by SPEC.
  514. `- iconic'
  515.      Start up iconified.
  516. `-reverse'
  517.      Bring up Emacs in reverse video.
  518. `-name'
  519.      Use the resource manager specified by NAME.
  520. `-xrm'
  521.      Read something into the resource database for this invocation of
  522.      Emacs.
  523. `-title TITLE'
  524.      Same as `-wn', sets the window title using `window-title-format'.
  525. File: lemacs,  Node: Basic,  Next: Undo,  Prev: Command Switches,  Up: Top
  526. Basic Editing Commands
  527. **********************
  528.    We now give the basics of how to enter text, make corrections, and
  529. save the text in a file.  If this material is new to you, you might
  530. learn it more easily by running the Emacs learn-by-doing tutorial.  To
  531. do this, type `Control-h t' (`help-with-tutorial').
  532. Inserting Text
  533. ==============
  534.    To insert printing characters into the text you are editing, just
  535. type them.  This inserts the characters into the buffer at the cursor
  536. (that is, at "point"; *note Point::.).  The cursor moves forward.  Any
  537. characters after the cursor move forward too.  If the text in the buffer
  538. is `FOOBAR', with the cursor before the `B' and you type `XX', the
  539. result is `FOOXXBAR', with the cursor still before the `B'.
  540.    To "delete" text you have just inserted, use DEL.  DEL deletes the
  541. character BEFORE the cursor (not the one that the cursor is on top of
  542. or under; that is the character AFTER the cursor).  The cursor and all
  543. characters after it move backwards.  Therefore, if you type a printing
  544. character and then type DEL, they cancel out.
  545.    To end a line and start typing a new one, type RET.  This inserts a
  546. newline character in the buffer.  If point is in the middle of a line,
  547. RET splits the line.  Typing DEL when the cursor is at the beginning of
  548. a line rubs out the newline before the line, thus joining the line with
  549. the preceding line.
  550.    Emacs automatically splits lines when they become too long, if you
  551. turn on a special mode called "Auto Fill" mode.  *Note Filling::, for
  552. information on using Auto Fill mode.
  553.    Customization information: DEL, in most modes, runs the command
  554. `delete-backward-char'; RET runs the command `newline', and
  555. self-inserting printing characters run the command `self-insert', which
  556. inserts whatever character was typed to invoke it.  Some major modes
  557. rebind DEL to other commands.
  558.    Direct insertion works for printing characters and SPC, but other
  559. characters act as editing commands and do not insert themselves.  If
  560. you need to insert a control character or a character whose code is
  561. above 200 octal, you must "quote" it by typing the character
  562. `control-q' (`quoted-insert') first.  There are two ways to use `C-q':
  563.    * `Control-q' followed by any non-graphic character (even `C-g')
  564.      inserts that character.
  565.    * `Control-q' followed by three octal digits inserts the character
  566.      with the specified character code.
  567. A numeric argument to `C-q' specifies how many copies of the quoted
  568. character should be inserted (*note Arguments::.).
  569.    If you prefer to have text characters replace (overwrite) existing
  570. text instead of moving it to the right, you can enable Overwrite mode, a
  571. minor mode.  *Note Minor Modes::.
  572. Changing the Location of Point
  573. ==============================
  574.    To do more than insert characters, you have to know how to move point
  575. (*note Point::.).  Here are a few of the available commands.
  576. `C-a'
  577.      Move to the beginning of the line (`beginning-of-line').
  578. `C-e'
  579.      Move to the end of the line (`end-of-line').
  580. `C-f'
  581.      Move forward one character (`forward-char').
  582. `C-b'
  583.      Move backward one character (`backward-char').
  584. `M-f'
  585.      Move forward one word (`forward-word').
  586. `M-b'
  587.      Move backward one word (`backward-word').
  588. `C-n'
  589.      Move down one line, vertically (`next-line').  This command
  590.      attempts to keep the horizontal position unchanged, so if you start
  591.      in the middle of one line, you end in the middle of the next.  When
  592.      on the last line of text, `C-n' creates a new line and moves onto
  593.      it.
  594. `C-p'
  595.      Move up one line, vertically (`previous-line').
  596. `C-l'
  597.      Clear the screen and reprint everything (`recenter').  Text moves
  598.      on the screen to bring point to the center of the window.
  599. `M-r'
  600.      Move point to left margin on the line halfway down the screen or
  601.      window (`move-to-window-line').  Text does not move on the screen.
  602.      A numeric argument says how many screen lines down from the top
  603.      of the window (zero for the top).  A negative argument counts from
  604.      the bottom (-1 for the bottom).
  605. `C-t'
  606.      Transpose two characters, the ones before and after the cursor
  607.      (`transpose-chars').
  608. `M-<'
  609.      Move to the top of the buffer (`beginning-of-buffer').  With
  610.      numeric argument N, move to N/10 of the way from the top.  *Note
  611.      Arguments::, for more information on numeric arguments.
  612. `M->'
  613.      Move to the end of the buffer (`end-of-buffer').
  614. `M-x goto-char'
  615.      Read a number N and move the cursor to character number N.
  616.      Position 1 is the beginning of the buffer.
  617. `M-x goto-line'
  618.      Read a number N and move cursor to line number N.  Line 1 is the
  619.      beginning of the buffer.
  620. `C-x C-n'
  621.      Use the current column of point as the "semi-permanent goal
  622.      column" for `C-n' and `C-p' (`set-goal-column').  Henceforth, those
  623.      commands always move to this column in each line moved into, or as
  624.      close as possible given the contents of the line.  This goal
  625.      column remains in effect until canceled.
  626. `C-u C-x C-n'
  627.      Cancel the goal column.  Henceforth, `C-n' and `C-p' once again
  628.      try to avoid changing the horizontal position, as usual.
  629.    If you set the variable `track-eol' to a non-`nil' value, `C-n' and
  630. `C-p' move to the end of the line when at the end of the starting line.
  631. By default, `track-eol' is `nil'.
  632. Erasing Text
  633. ============
  634. `DEL'
  635.      Delete the character before the cursor (`delete-backward-char').
  636. `C-d'
  637.      Delete the character after the cursor (`delete-char').
  638. `C-k'
  639.      Kill to the end of the line (`kill-line').
  640. `M-d'
  641.      Kill forward to the end of the next word (`kill-word').
  642. `M-DEL'
  643.      Kill back to the beginning of the previous word
  644.      (`backward-kill-word').
  645.    In contrast to the DEL key, which deletes the character before the
  646. cursor, `Control-d' deletes the character after the cursor, causing the
  647. rest of the text on the line to shift left.  If `Control-d' is typed at
  648. the end of a line, that line and the next line are joined.
  649.    To erase a larger amount of text, use `Control-k', which kills a
  650. line at a time.  If you use `C-k' at the beginning or in the middle of
  651. a line, it kills all the text up to the end of the line.  If you use
  652. `C-k' at the end of a line, it joins that line and the next line.
  653.    *Note Killing::, for more flexible ways of killing text.
  654. Files
  655. =====
  656.    The commands above are sufficient for creating and altering text in
  657. an Emacs buffer.  More advanced Emacs commands just make things easier.
  658. But to keep any text permanently you must put it in a "file".  Files
  659. are named units of text which are stored by the operating system and
  660. which you can retrieve by name.  To look at or use the contents of a
  661. file in any way, including editing the file with Emacs, you must
  662. specify the file name.
  663.    Consider a file named `/usr/rms/foo.c'.  To begin editing this file
  664. from Emacs, type
  665.      C-x C-f /usr/rms/foo.c RET
  666. The file name is given as an "argument" to the command `C-x C-f'
  667. (`find-file').  The command uses the "minibuffer" to read the argument.
  668. You have to type RET to terminate the argument (*note Minibuffer::.).
  669.    You can also use the Open File... menu item from the File menu, then
  670. type the name of the file to the prompt.
  671.    Emacs obeys the command by "visiting" the file: it creates a buffer,
  672. copies the contents of the file into the buffer, and then displays the
  673. buffer for you to edit.  You can make changes in the buffer, and then
  674. "save" the file by typing `C-x C-s' (`save-buffer') or choosing Save
  675. Buffer from the File menu.  This makes the changes permanent by copying
  676. the altered contents of the buffer back into the file `/usr/rms/foo.c'.
  677. Until then, the changes are only inside your Emacs buffer, and the
  678. file `foo.c' is not changed.
  679.    To create a file, visit the file with `C-x C-f' as if it already
  680. existed or choose Open File from the File menu and provide the name for
  681. the new file in the minibuffer.  Emacs will create an empty buffer in
  682. which you can insert the text you want to put in the file.  When you
  683. save the buffer with `C-x C-s', or by choosing Save Buffer from the
  684. File menu, the file is created.
  685.    To learn more about using files, *note Files::..
  686.    If you forget what a key does, you can use the Help character, `C-h'
  687. to find out: Type `C-h k' followed by the key you want to know about.
  688. For example, `C-h k C-n' tells you what `C-n' does.  `C-h' is a prefix
  689. key; `C-h k' is just one of its subcommands (the command
  690. `describe-key').  The other subcommands of `C-h' provide different
  691. kinds of help.  Type `C-h' three times to get a description of all the
  692. help facilities.  *Note Help::.
  693. * Menu:
  694. * Blank Lines::        Commands to make or delete blank lines.
  695. * Continuation Lines:: Lines too wide for the screen.
  696. * Position Info::      What page, line, row, or column is point on?
  697. * Arguments::           Numeric arguments for repeating a command.
  698. File: lemacs,  Node: Blank Lines,  Next: Continuation Lines,  Prev: Basic,  Up: Basic
  699. Blank Lines
  700. ===========
  701.    Here are special commands and techniques for entering and removing
  702. blank lines.
  703. `C-o'
  704.      Insert one or more blank lines after the cursor (`open-line').
  705. `C-x C-o'
  706.      Delete all but one of many consecutive blank lines
  707.      (`delete-blank-lines').
  708.    When you want to insert a new line of text before an existing line,
  709. you just type the new line of text, followed by RET.  If you prefer to
  710. first create a blank line and then insert the desired text, use the key
  711. `C-o' (`open-line'), which inserts a newline after point but leaves
  712. point in front of the newline.  Then type the text into the new line.
  713. `C-o F O O' has the same effect as `F O O RET', except for the final
  714. location of point.
  715.    To create several blank lines, type `C-o' several times, or give
  716. `C-o' an argument indicating how many blank lines to create.  *Note
  717. Arguments::, for more information.
  718.    If you have many blank lines in a row and want to get rid of them,
  719. use `C-x C-o' (`delete-blank-lines').  If point is on a blank line
  720. which is adjacent to at least one other blank line, `C-x C-o' deletes
  721. all but one of the blank lines.  If point is on a blank line with no
  722. other adjacent blank line, the sole blank line is deleted.  If point is
  723. on a non-blank line, `C-x C-o' deletes any blank lines following that
  724. non-blank line.
  725. File: lemacs,  Node: Continuation Lines,  Next: Position Info,  Prev: Blank Lines,  Up: Basic
  726. Continuation Lines
  727. ==================
  728.    If you add too many characters to one line without breaking with a
  729. RET, the line grows to occupy two (or more) screen lines, with a curved
  730. arrow at the extreme right margin of all but the last line.  The curved
  731. arrow indicates that the following screen line is not really a distinct
  732. line in the text, but just the "continuation" of a line too long to fit
  733. the screen.  You can use Auto Fill mode, (*note Filling::.), to have
  734. Emacs insert newlines automatically when a line gets too long.
  735.    Instead of continuation, long lines can be displayed by "truncation".
  736. This means that all the characters that do not fit in the width of the
  737. screen or window do not appear at all.  They remain in the buffer,
  738. temporarily invisible.  Three diagonal dots in the last column (instead
  739. of the curved arrow inform you that truncation is in effect.
  740.    To turn off continuation for a particular buffer set the variable
  741. `truncate-lines' to non-`nil' in that buffer.  Truncation instead of
  742. continuation also happens whenever horizontal scrolling is in use, and
  743. optionally whenever side-by-side windows are in use (*note Windows::.).
  744. Altering the value of `truncate-lines' makes it local to the current
  745. buffer; until that time, the default value is in effect.  The default
  746. is initially `nil'.  *Note Locals::.
  747. File: lemacs,  Node: Position Info,  Next: Arguments,  Prev: Continuation Lines,  Up: Basic
  748. Cursor Position Information
  749. ===========================
  750.    If you are accustomed to other display editors, you may be surprised
  751. that Emacs does not always display the page number or line number of
  752. point in the mode line.  In Emacs, this information is only rarely
  753. needed, and a number of commands are available to compute and print it.
  754. Since text is stored in a way that makes it difficult to compute the
  755. information, it is not displayed all the time.
  756. `M-x what-page'
  757.      Print page number of point, and line number within page.
  758. `M-x what-line'
  759.      Print line number of point in the buffer.
  760. `M-='
  761.      Print number of lines in the current region (`count-lines-region').
  762. `C-x ='
  763.      Print character code of character after point, character position
  764.      of point, and column of point (`what-cursor-position').
  765.    There are several commands for printing line numbers:
  766.    * `M-x what-line' counts lines from the beginning of the file and
  767.      prints the line number point is on.  The first line of the file is
  768.      line number 1.  You can use these numbers as arguments to `M-x
  769.      goto-line'.
  770.    * `M-x what-page' counts pages from the beginning of the file, and
  771.      counts lines within the page, printing both of them.  *Note
  772.      Pages::, for the command `C-x l' which counts the lines in the
  773.      current page.
  774.    * `M-=' (`count-lines-region'), prints the number of lines in the
  775.      region (*note Mark::.).
  776.    The command `C-x =' (`what-cursor-position') provides information
  777. about point and about the column the cursor is in.  It prints a line in
  778. the echo area that looks like this:
  779.      Char: x (0170)  point=65986 of 563027(12%)  x=44
  780. (In fact, this is the output produced when point is before the `x=44'
  781. in the example.)
  782.    The two values after `Char:' describe the character following point,
  783. first by showing it and second by giving its octal character code.
  784.    `point=' is followed by the position of point expressed as a
  785. character count.  The front of the buffer counts as position 1, one
  786. character later as 2, and so on.  The next, larger number is the total
  787. number of characters in the buffer.  Afterward in parentheses comes the
  788. position expressed as a percentage of the total size.
  789.    `x=' is followed by the horizontal position of point, in columns
  790. from the left edge of the window.
  791.    If the buffer has been narrowed, making some of the text at the
  792. beginning and the end temporarily invisible, `C-x =' prints additional
  793. text describing the current visible range.  For example, it might say
  794.      Char: x (0170)  point=65986 of 563025(12%) <65102 - 68533>  x=44
  795. where the two extra numbers give the smallest and largest character
  796. position that point is allowed to assume.  The characters between those
  797. two positions are the visible ones.  *Note Narrowing::.
  798.    If point is at the end of the buffer (or the end of the visible
  799. part), `C-x =' omits any description of the character after point.  The
  800. output looks like
  801.      point=563026 of 563025(100%)  x=0
  802. File: lemacs,  Node: Arguments,  Prev: Position Info,  Up: Basic
  803. Numeric Arguments
  804. =================
  805.    Any Emacs command can be given a "numeric argument".  Some commands
  806. interpret the argument as a repetition count.  For example, giving an
  807. argument of ten to the key `C-f' (the command `forward-char', move
  808. forward one character) moves forward ten characters.  With these
  809. commands, no argument is equivalent to an argument of one.  Negative
  810. arguments are allowed.  Often they tell a command to move or act
  811. backwards.
  812.    If your keyboard has a META key, the easiest way to specify a
  813. numeric argument is to type digits and/or a minus sign while holding
  814. down the the META key.  For example,
  815.      M-5 C-n
  816. moves down five lines.  The characters `Meta-1', `Meta-2', and so on,
  817. as well as `Meta--', do this because they are keys bound to commands
  818. (`digit-argument' and `negative-argument') that are defined to
  819. contribute to an argument for the next command.
  820.    Another way of specifying an argument is to use the `C-u'
  821. (`universal-argument') command followed by the digits of the argument.
  822. With `C-u', you can type the argument digits without holding down shift
  823. keys.  To type a negative argument, start with a minus sign.  Just a
  824. minus sign normally means -1.  `C-u' works on all terminals.
  825.    `C-u' followed by a character which is neither a digit nor a minus
  826. sign has the special meaning of "multiply by four".  It multiplies the
  827. argument for the next command by four.  `C-u' twice multiplies it by
  828. sixteen.  Thus, `C-u C-u C-f' moves forward sixteen characters.  This
  829. is a good way to move forward "fast", since it moves about 1/5 of a line
  830. in the usual size screen.  Other useful combinations are `C-u C-n',
  831. `C-u C-u C-n' (move down a good fraction of a screen), `C-u C-u C-o'
  832. (make "a lot" of blank lines), and `C-u C-k' (kill four lines).
  833.    Some commands care only about whether there is an argument, and not
  834. about its value.  For example, the command `M-q' (`fill-paragraph') with
  835. no argument fills text; with an argument, it justifies the text as well.
  836. (*Note Filling::, for more information on `M-q'.)  Just `C-u' is a
  837. handy way of providing an argument for such commands.
  838.    Some commands use the value of the argument as a repeat count, but do
  839. something peculiar when there is no argument.  For example, the command
  840. `C-k' (`kill-line') with argument N kills N lines, including their
  841. terminating newlines.  But `C-k' with no argument is special: it kills
  842. the text up to the next newline, or, if point is right at the end of
  843. the line, it kills the newline itself.  Thus, two `C-k' commands with
  844. no arguments can kill a non-blank line, just like `C-k' with an
  845. argument of one.  (*Note Killing::, for more information on `C-k'.)
  846.    A few commands treat a plain `C-u' differently from an ordinary
  847. argument.  A few others may treat an argument of just a minus sign
  848. differently from an argument of -1.  These unusual cases will be
  849. described when they come up; they are always for reasons of convenience
  850. of use of the individual command.
  851. File: lemacs,  Node: Undo,  Next: Minibuffer,  Prev: Basic,  Up: Top
  852. Undoing Changes
  853. ***************
  854.    Emacs allows you to undo all changes you make to the text of a
  855. buffer, up to a certain amount of change (8000 characters).  Each
  856. buffer records changes individually, and the undo command always
  857. applies to the current buffer.  Usually each editing command makes a
  858. separate entry in the undo records, but some commands such as
  859. `query-replace' make many entries, and very simple commands such as
  860. self-inserting characters are often grouped to make undoing less
  861. tedious.
  862. `C-x u'
  863.      Undo one batch of changes (usually, one command worth) (`undo').
  864. `C-_'
  865.      The same.
  866.    The command `C-x u' or `C-_' allows you to undo changes.  The first
  867. time you give this command, it undoes the last change.  Point moves to
  868. the text affected by the undo, so you can see what was undone.
  869.    Consecutive repetitions of the `C-_' or `C-x u' commands undo
  870. earlier and earlier changes, back to the limit of what has been
  871. recorded.  If all recorded changes have already been undone, the undo
  872. command prints an error message and does nothing.
  873.    Any command other than an undo command breaks the sequence of undo
  874. commands.  Starting at this moment, the previous undo commands are
  875. considered ordinary changes that can themselves be undone.  Thus, you
  876. can redo changes you have undone by typing `C-f' or any other command
  877. that have no important effect, and then using more undo commands.
  878.    If you notice that a buffer has been modified accidentally, the
  879. easiest way to recover is to type `C-_' repeatedly until the stars
  880. disappear from the front of the mode line.  When that happens, all the
  881. modifications you made have been cancelled.  If you do not remember
  882. whether you changed the buffer deliberately, type `C-_' once. When you
  883. see Emacs undo the last change you made, you probably remember why you
  884. made it.  If the change was an accident, leave it undone.  If it was
  885. deliberate, redo the change as described in the preceding paragraph.
  886.    Whenever an undo command makes the stars disappear from the mode
  887. line, the buffer contents is the same as it was when the file was last
  888. read in or saved.
  889.    Not all buffers record undo information.  Buffers whose names start
  890. with spaces don't; these buffers are used internally by Emacs and its
  891. extensions to hold text that users don't normally look at or edit.
  892. Minibuffers, help buffers and documentation buffers also don't record
  893. undo information.
  894.    Emacs can remember at most 8000 or so characters of deleted or
  895. modified text in any one buffer for reinsertion by the undo command.
  896. There is also a limit on the number of individual insert, delete or
  897. change actions that Emacs can remembered.
  898.    There are two keys to run the `undo' command, `C-x u' and `C-_',
  899. because on some keyboards, it is not obvious how to type `C-_'. `C-x u'
  900. is an alternative you can type in the same fashion on any terminal.
  901.